@include('backstage/public/_header')
    <!--搜索结果页面 列表 开始-->
    <div class="result_wrap">
        <!--快捷导航 开始-->
        @if( session()->has('notice') )
            <div class="result_title">
                <div class="mark">
                    <p style="color: red">{{ session()->get('notice') }}</p>
                </div>
            </div>    
        @endif
        
        <div class="result_content">
            <div class="short_wrap">
                <a href="add"><i class="fa fa-plus"></i>添加廣告</a>
                <a href="javascript:void(0);" onclick="window.location.reload();"><i class="fa fa-refresh"></i>更新排序</a>
            </div>
        </div>
        <!--快捷导航 结束-->
    </div>

    <div class="result_wrap">
        <div class="result_content">
            <table class="list_tab">
                <tr>
                    <th class="tc" width="2%"><input type="checkbox" id="checkAll" value="0"></th>
                    <!-- <th class="tc" width="5%">排序</th> -->
                    <th class="tc">ID</th>
                    <th>版位名称</th>
                    <th>类型</th>
                    <th>开始时间</th>
                    <th>结束时间</th>
                    <th>添加时间</th>
                    <th>版位描述</th>
                    <th>操作</th>
                </tr>
                @foreach( $list as $k => $v )
                <tr id="list_{{$v->id}}">
                    <td class="tc"><input type="checkbox" name="checkbox" value="{{$v->id}}"></td>
                    <td class="tc">{{ $v->id }}</td>
                    <td>{{ $v->name }}</td>
                    <td>{{ $v->type }}</td>
                    <td>@if($v->start_time!=0) {{date('Y-m-d H:i:s',$v->start_time)}} @endif</td>
                    <td>@if($v->end_time!=0) {{date('Y-m-d H:i:s',$v->end_time)}} @endif</td>
                    <td>@if($v->add_time!=0) {{date('Y-m-d H:i:s',$v->add_time)}} @endif</td>
                    <td>{{$v->desc}}</td>
                    <td>
                        <a href="edit/{{$v->id}}">修改</a>
                        <a href="javascript:void(0);" onclick="del({{$v->id}});">刪除</a>
                    </td>
                </tr>
                @endforeach
            </table>
            
        </div>
    </div>
    <!--搜索结果页面 列表 结束-->
    <script type="text/javascript">
    function getChecked() {
        var gids = new Array();
        $.each($('input:checked'), function(i, n){
            if($(n).val()!=0) gids.push( $(n).val() );
        });
        return gids;
    }
    //刪除
    function del(aid){
        aid = aid ? aid : getChecked();
        // console.log(aid);
        //詢問框
        layer.confirm('刪除後不可恢復，確定要刪除嗎？', {
          btn: ['確定','取消'] //按鈕
        }, function(){
            aid = aid.toString();
            // console.log(aid);
            if(aid == '') return layer.msg('未選中任何數據', {icon: 2,anim: 6});
            // layer.msg('正在刪除...', {icon: 16,shade: 0.01});
            $.post("{{$dodel}}", { 'idstr':aid,"_token":"{{ csrf_token() }}"},
            function (data){
                if(data.status==1){
                    layer.msg('正在刪除...', {icon: 16,shade: 0.01});
                    setTimeout(function(){
                        aid = aid.split(',');
                        $.each(aid, function(i,n){
                            $('#list_'+n).remove();
                        });
                        layer.msg(data.message, {icon: 1});
                    },2000);
                }else if(data.status==0){
                    layer.msg(data.message, {icon: 2});
                }else if(data.status==-1){
                    layer.alert(data.message, {icon: 2,anim:6});
                }else if(data.status==2){
                    layer.msg(data.message, {icon: 7});
                }else{
                    layer.msg('未知原因，刪除失敗', {icon: 2});
                }
            }, "json");
        });
        
    }
    </script>
@include('backstage/public/_footer')